package com.wobito.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wobito.common.utils.DateUtils;
import com.wobito.mapper.DeviceLogMapper;
import com.wobito.pojo.bean.DeviceLog;
import com.wobito.pojo.dto.log.DeviceLogDTO;
import com.wobito.pojo.vo.log.AddDeviceLog;
import com.wobito.pojo.vo.log.DeviceLogVO;
import com.wobito.service.IDeviceLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lambyang
 * @since 2024-09-02
 */
@Service
public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog> implements IDeviceLogService {

    @Autowired
    private DeviceLogMapper deviceLogMapper;

    @Override
    public List<DeviceLogDTO> selectDeviceList(DeviceLogVO deviceLogVO) {
        return deviceLogMapper.selectDeviceLogList(deviceLogVO);
    }

    @Override
    public int insertDeviceLog(DeviceLog deviceLog) {
        AddDeviceLog addDeviceLog= BeanUtil.copyProperties(deviceLog, AddDeviceLog.class);
        addDeviceLog.setTableInfo(DateUtils.getYearAndMonth());
        return deviceLogMapper.insertDeviceLog(addDeviceLog);
    }
}
